package com.xiangty.ssmtemplate.service.impl;

import com.xiangty.ssmtemplate.entity.User;
import com.xiangty.ssmtemplate.dao.UserMapper;
import com.xiangty.ssmtemplate.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Classname UserServiceImpl
 * @Description TODO
 * @Date 2019/6/8 21:17
 * @Created by xiangty
 */

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> queryUserList() {
        return userMapper.queryUserList();
    }

    @Transactional
    @Override
    public Integer saveUser(User user) {
        return userMapper.saveUser(user);
    }

    @Transactional
    @Override
    public Integer updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public User getUserByName(String username) {
        return userMapper.getUserByName(username);
    }

    @Override
    public User getUserById(Integer id) {
        return userMapper.getUserById(id);
    }

    @Transactional
    @Override
    public Integer deleteById(Integer id) {
        return userMapper.deleteById(id);
    }

}
